{extend name="ace/layout/master/detail" /}

{block name="title"}角色管理{/block}

{block name="page-title"}角色{/block}

{block name="style-src"}
<link rel="stylesheet" href="__ADMIN__/css/adminroles.css?v={:config('cnpscy.resource_version_number')}">
{/block}

{block name="content"}
    <input name="role_id" class="form-control" type="hidden" value="{if $detail}{$detail->role_id}{/if}" />
    <div class="form-group">
        <label class="col-sm-3 control-label no-padding-right"> 角色名称：</label>
        <div class="col-sm-9">
            <input type="text" name="role_name" placeholder="输入角色名称" class="col-xs-10 col-sm-5" required="" value="{if $detail}{$detail->role_name}{/if}" />
            <span class="lbl col-xs-12 col-sm-7">
                <i class="icon-info-sign"></i> 唯一标识
            </span>
        </div>
    </div>
    <div class="space-4"></div>
    <div class="form-group">
        <label class="col-sm-3 control-label no-padding-right"> 备注：</label>
        <div class="col-sm-9">
            <textarea name="role_remarks" class="col-xs-10 col-sm-5">{if $detail}{$detail->role_remarks}{/if}</textarea>
        </div>
    </div>
    <div class="space-4"></div>
    <div class="form-group">
        <label class="col-sm-3 control-label no-padding-right">
            是否启用：
        </label>
        <div class="col-sm-9 radio">
            <label>
                <input name="is_check" type="radio" class="ace" value="1" {if (empty($detail) || $detail->is_check === 1) }checked{/if} />
                <span class="lbl"> 启用 </span>
            </label>
            <label>
                <input name="is_check" type="radio" class="ace" value="0" {if (empty($detail) || $detail->is_check === 0) }checked{/if} />
                <span class="lbl"> 禁用 </span>
            </label>
        </div>
    </div>
    <div class="space-4"></div>
    <div class="form-group">
        <label class="col-sm-3 control-label no-padding-right">
            权限分配：
        </label>
        <div class="col-sm-9">

        </div>
    </div>
    <hr>
    <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tbody>
        <tr>
            <td height="30" style="padding-left:10px;border-bottom:#CCCCCC solid 1px; line-height:25px; background-color:#F4F8FB">
                <label class="pos-rel">
                    <input type="checkbox" class="ace ace-checkbox-2 checkAll-true" onclick="checkAll(true)" value="全选">
                    <span class="lbl"> 权限全选</span>
                </label>
                &nbsp;&nbsp;&nbsp;
                <label class="pos-rel">
                    <input type="checkbox" class="ace ace-checkbox-2 checkAll-false" onclick="checkAll(false)" value="全选">
                    <span class="lbl"> 取消全选</span>
                </label>
            </td>
        </tr>
        </tbody>
    </table>

{/block}

{block name="script"}
<script type="text/javascript">
    window.onload = function () {
        closeLayerLoading(closeAllLayer);

        var has_menus = JSON.parse('{:html_get_res_from_admin($detail->menus ?? [])}');
        console.log(has_menus);

        let menu_ids = new Array();
        for (var i = 0; i < has_menus.length; i++) {
            menu_ids.push(has_menus[i].menu_id);
        }
        console.log(menu_ids);

        var all_menus = JSON.parse('{:html_get_res_from_admin($menus ?? [])}');

        getRoleSelectMenusList(all_menus, menu_ids);
    }
</script>
{/block}